#!/bin/bash
set -euxo pipefail

pg_isready --dbname="${DB_DATABASE_NAME}" --username="${DB_USERNAME}"  || exit 1
Chksum=$(psql --dbname="${DB_DATABASE_NAME}" --username="${DB_USERNAME}" --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')
echo "checksum failure count is $Chksum"
[ "$Chksum" = '0' ] || exit 1